package com.funny.test;

import com.funny.app.LocalTest;
import com.funny.mapper.LocalTestMapper;
import com.funny.service.LocalTestService;
import com.funny.test.config.DataSourceConfig;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author fanxiao  2022/1/17
 * @since 1.0.0
 */
@Slf4j
public class LocalTestUnit {

	@Test
	public void localTestInsert() throws Exception {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
		context.register(DataSourceConfig.class);
		context.refresh();

		LocalTestService service = context.getBean(LocalTestService.class);
		LocalTest localTest = new LocalTest();
		localTest.setName("令狐冲");
		service.insert(localTest);
	}

	@Test
	public void localTestDecrypt() throws Exception {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
		context.register(DataSourceConfig.class);
		context.refresh();
		LocalTestService service = context.getBean(LocalTestService.class);
		LocalTest localTest = service.selectById(9L);
		log.info("{}", localTest);
	}

	@Test
	public void localTestUpdateNameById() throws Exception {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
		context.register(DataSourceConfig.class);
		context.refresh();
		LocalTestService service = context.getBean(LocalTestService.class);
		service.updateNameById("令狐冲1", 9L);
	}
}